/**
 * Created by shanyun.gu on 2017/3/21.
 */
define(['jquery'], function ($) {
    return function (url, type, data, successFn, alwaysFn) {
        $.ajax({
            url:  url,
            type: type,
            data:  "params=" + JSON.stringify(data),
            dataType: "json"
        }).done(
            function (responseJson) {
                if (typeof  successFn === "function") {
                    successFn(responseJson);
                }
            }).fail(function(){alert("服务器异常")}).always(
            function () {
                if (typeof alwaysFn === "function") {
                    alwaysFn();
                }
            }
        );
    };
});